<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let num = +prompt('输入一个数字，判断他是不是质数')
      let count = 0
      if(num === 1){
        alert(`质数排除1`)
      } else if (num > 0){
        for(let i = 2;i<= num;i++){
          if (num % i === 0){
            count++
          }
        }
        if (count === 1){
          alert(`${num}是质数`)

        } else {
          alert(`${num}不是质数`)
        }
      } else  {
        alert('请输入正整数')
      }
    </script>
  </body>
</html>
